<template>
	<view class="pg-content">
		<view class="pg-main">
			<view class="bf-vimage">
				<!-- <video :src="getBackEffectUrl()" controls>
				</video> -->
			</view>
			<button @click="test()">测试get</button>
			<button @click="test2()">测试pos</button>
			<button @click="testFile()">file</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				current: 0,
				previewUrl: '',
				effects: []
			}
		},
		onLoad() {
			
			
		},
		methods: {
			getBackEffectUrl() {
				//return `${window.location.origin}/index`;
				return '';
			},
			test() {
				console.log(123);
				uni.request({
				  url: '/test',
				  method: 'GET',
				  data: {
					  name: 'dfsdtt测试',
					  large: 1235,
					  test: 'succesdf'
				  },
				  /* header: {
				    'Content-Type': 'application/x-www-form-urlencoded'
				  }, */
				  success: function(res) {
				    
				  }
				});
			},
			test2() {
				console.log(123);
				uni.request({
				  url: '/test',
				  method: 'POST',
				  data: {
					  name: 'dfsdtt测试',
					  large: 1235,
					  test: 'succesdf'
				  },
				  /* header: {
				    'Content-Type': 'application/x-www-form-urlencoded'
				  }, */
				  success: function(res) {
				    
				  }
				});
			},
			testFile() {
				uni.chooseFile({
					type: 'image',
					success: res=> {
						const filePaths = res.tempFiles;
						let desFiles = [];
						console.log(filePaths);
						filePaths.forEach(file=> {
							desFiles.push({url: file.path, file: file})
						});
						this.upload(desFiles);
					}
				});
			},
			upload(objs) {
				var task = uni.uploadFile({
					url: '/test/uploadFile',
					files: objs,
					formData: {
						name: "zhangsan",
						nick: "looking"
					},
					success: res => {
						
					}
				});
				task.onProgressUpdate(res=> {
					this.percent = res.progress;
				})
			}
		}
	}
</script>

<style>
	.bf-for {
		display: flex;
		padding: 26rpx 26rpx 52rpx 26rpx;
	}

	.bf-for view {
		display: flex;
		align-items: center;
	}

	.bf-for text {
		flex: auto;
		margin-left: 8px;
	}

	.bf-vimage {
		position: relative;
	}

	.bf-vimage video {
		border: 1px solid #eee;
		z-index: 0;
	}

	.bf-vimage view {
		background: #7F7F7F;
		position: absolute;
		bottom: 3px;
		right: 3px;
		padding: 2px 4px;
		font-size: 10px;
		color: #fafafa;
		border-radius: 8px 0px 8px 0px;
	}

	.pre-video {
		width: 100vw;
		height: 33vh;
	}

	.btn-bottom {
		bottom: 26rpx;
		margin: 0 26rpx;
	}
</style>